#  Copyright (c) 2021
#  User:SDUFE-Zhaocheng Lu
#  File:get_user_data.py
#  Date:2021/08/16 23:45:16

import datetime
import lib


def get_user_data(where=''):
    SQL = lib.SQL()
    results = SQL.select('*', 'userprofile', where)
    usr_list = []
    for result in results:
        fin = {'usr_info': {}}
        for i, name in enumerate(lib.field_name):
            if i < 3:
                fin[name] = result[i]
            else:
                fin['usr_info'][name] = result[i]
        span_days = (result[-2] - datetime.date.today()).days
        if span_days >= 0:
            usr_list.append(fin)
    return usr_list
